package vuelos;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

@SuppressWarnings("serial")
public class JNovaButton extends JButton {
	
  private Shape figura;
  Icon ButtonFree;
  Icon ButtonArmed;
  

  // Constructor
  public JNovaButton(String IconFree, String IconArmed) {
	  
    super("");

    setContentAreaFilled( false );
    
    ButtonFree  = new ImageIcon(getClass().getResource(IconFree));
    ButtonArmed = new ImageIcon(getClass().getResource(IconArmed));
    
    this.setIcon(ButtonFree);
    this.setPressedIcon(ButtonArmed);
    
    Dimension Size = new Dimension(ButtonFree.getIconHeight()-2, ButtonFree.getIconHeight()-2);
    setPreferredSize(Size);
    
    this.setFocusPainted(false);
    
  }

  // Redefinicion del metodo Paint 
  // Dibuja el interior del Boton
  protected void paintComponent(Graphics g) {
	
	g.setColor(getBackground());
    g.fillOval( 0,0,ButtonFree.getIconWidth()-2, ButtonFree.getIconWidth()-2);
    super.paintComponent( g );
  
  }

  // Redefinicion del metodo paintBorder 
  // Dibuja en borde del Boton
  protected void paintBorder(Graphics g) {
    
  }

  // Redefinicion del metodo contains 
  // Controla si el cursor esta sobre el boton
  public boolean contains( int x,int y ) {
    
    figura = new Ellipse2D.Float(0,0,ButtonFree.getIconWidth()-2, ButtonFree.getIconHeight()-2);
	  
    return( figura.contains( x,y ) );
    
  }
  
}
